#ifndef DEBOUNCEHANDLER_H
#define DEBOUNCEHANDLER_H

#include <QObject>
#include <QTimer>
#include <QHash>

class DebounceHandler : public QObject {
    Q_OBJECT
public:
    static DebounceHandler* instance() {
        static DebounceHandler handler;
        return &handler;
    }

    void triggerAction(QObject *sender, std::function<void()> action, int delay = 500);

private:
    QHash<QObject*, QTimer*> m_timers; // 存储各控件对应的计时器
};

#endif // DEBOUNCEHANDLER_H
